<?php
include DOCUMENT_ROOT."/Framework/controller.class.php";


// =============================================================================
/*
 * 登录
 */
class UserController extends controller{
   
    public function denglu(){
         parent::header();
         parent::smartyAction("User");
        $this->smarty->display("denglu.html");
    }
    
    public function check(){
        $name=$_GET["name"];
        $pwd=$_GET["pwd"];
        include DOCUMENT_ROOT."/Application/User/model/UserModel.class.php";
        $UserModel=new UserModel();
        $result=$UserModel->select("name='$name' And pwd='$pwd'");
        if($result){
            echo 1;
        }else{
            echo 0;
        }      
    }
    
// =============================================================================
   /*
    * 列表
    */

    public function liebiao(){
         parent::header();
         parent::smartyAction("User");
        include DOCUMENT_ROOT."/Application/User/model/UserModel.class.php";
        $UserModel=new UserModel();
        $arr=$UserModel->liebiao();
        $this->smarty->assign("arr", $arr);
        $this->smarty->display("list.html");
    }
    
    
// =============================================================================
   /*
    * 详情
    */
   public function XQ(){
        parent::header();
        parent::smartyAction("User");
        include DOCUMENT_ROOT."/Application/User/model/UserModel.class.php";
        $UserModel=new UserModel();
        $id=$_GET["id"];
        $arr=$UserModel->xiangqing($id);
//        var_dump($arr);
        $this->smarty->assign("arr", $arr);
        $this->smarty->display("xiangqing.html");
    }
// =============================================================================
   /*
    * 发帖
    */
    
   public function Lj(){
        parent::header();
        parent::smartyAction("User");
        $this->smarty->display("fatie.html");
   }
   public function FT(){
        $biaoti=$_POST["biaoti"];
        $wenzhang=$_POST["wenzhang"];
        if($biaoti=="" || $wenzhang ==""){
            echo "不能为空";
            die();
        }else{
        include DOCUMENT_ROOT."/Application/User/model/UserModel.class.php";
        $UserModel=new UserModel();
        $arr=$UserModel->fatie($biaoti, $wenzhang);
        echo 1;
        }  
   }
   
// =============================================================================

    /*
     * 注册
     */
    public function ZCXS(){
         parent::header();
         parent::smartyAction("User");
        $this->smarty->display("zhuce.html");
    }
    
    public function PD(){
        $name=$_GET["name"];
        include DOCUMENT_ROOT."/Application/User/model/UserModel.class.php";
        $UserModel=new UserModel();
        $result=$UserModel->ZCCX("name=$name");
        if($result){
            echo "昵称可以用";
        }else{
            echo "昵称重复";
        }      
    }
    
    public function addUser(){
        $name=$_POST["name"];
        $pwd=$_POST["pwd"];
        include DOCUMENT_ROOT."/Application/User/model/UserModel.class.php";
        $UserModel=new UserModel();
        $result=$UserModel->adduser($name,$pwd);
        return $result;
    }

}


